const mongoose = require('mongoose');
const LoginSchema = mongoose.model('userLoginModel');
const admin = mongoose.model('adminsLoginModel');
const superadmin=mongoose.model('superadminModel')
async function login({ name, password, type,ice }) {  // {name}   {name, password}

    if (type == '商家') {
        const data = await admin.find({ name });
        
        return data;
    } else if (type == '用户') {
        const data = await LoginSchema.find({ name, password, type,ice }); 
        return data;
    }else{
        return await superadmin.find({ name });
    }
}
async function register({ name, password, type,ice }) {
    if (type == '商家') {
        const data = await admin.create({ name, password, type,ice }); return data;
    } else if (type == '用户') {
        const data = await LoginSchema.create({ name, password, type ,ice}); return data;
    }

}


module.exports = {
    login, register
}
